package cn.itcast.sys.controller;


import cn.itcast.constant.StatusConstant;
import cn.itcast.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
@Slf4j
public class ShopController {

    @Autowired
    RedisTemplate redisTemplate;

    @ApiOperation("获取营业状态")
    @GetMapping("/status")
    public Result getStatus(){
//        ValueOperations valueOperations = redisTemplate.opsForValue();
//        if( valueOperations.get(StatusConstant.BUSINESS_STATUS) == null ){
//            valueOperations.set(StatusConstant.BUSINESS_STATUS,StatusConstant.ENABLE);
//        }
//
//        Integer status = Integer.valueOf(valueOperations.get(StatusConstant.BUSINESS_STATUS)+"");

        System.out.println("接收到请求");
        return Result.success("恭喜你孩子，项目已经创建好了！");
    }

    @ApiOperation("设置营业状态")
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable Integer status){

        redisTemplate.opsForValue().set(StatusConstant.BUSINESS_STATUS,status);



        return Result.success();
    }

}

